package com.ruoyi.business.mapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.ruoyi.business.domain.EmployeeScore;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

/**
 * 员工积分Mapper接口
 * 
 * @author ruoyi
 * @date 2024-11-30
 */
public interface EmployeeScoreMapper 
{
    /**
     * 查询员工积分
     * 
     * @param id 员工积分主键
     * @return 员工积分
     */
    public EmployeeScore selectEmployeeScoreById(Long id);

    /**
     * 查询员工积分列表
     * 
     * @param employeeScore 员工积分
     * @return 员工积分集合
     */
    public List<EmployeeScore> selectEmployeeScoreList(EmployeeScore employeeScore);

    /**
     * 新增员工积分
     * 
     * @param employeeScore 员工积分
     * @return 结果
     */
    public int insertEmployeeScore(EmployeeScore employeeScore);

    /**
     * 修改员工积分
     * 
     * @param employeeScore 员工积分
     * @return 结果
     */
    public int updateEmployeeScore(EmployeeScore employeeScore);

    /**
     * 删除员工积分
     * 
     * @param id 员工积分主键
     * @return 结果
     */
    public int deleteEmployeeScoreById(Long id);

    /**
     * 批量删除员工积分
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteEmployeeScoreByIds(Long[] ids);

    public List<String>getAllYears(EmployeeScore employeeScore);



    List<Map<String, Object>> getBarData( EmployeeScore employeeScore);


    List<Map<String, Object>> getPieData(EmployeeScore employeeScore);

    List<String> getPersonalDataYears(EmployeeScore employeeScore);

    List<Map<String, Object>> getPersonalData(EmployeeScore employeeScore);

    @Delete("DELETE FROM t_employee_Score")
    void clearTable();

    //WHERE DATE_FORMAT(award_year, '%Y') = DATE_FORMAT(NOW(), '%Y')
    @Delete("DELETE FROM t_employee_Score WHERE DATE_FORMAT(award_year, '%Y') = DATE_FORMAT(NOW(), '%Y')")
    void clearTableCurrent();

    List<Map<String, Object>> getRatingStar(EmployeeScore employeeScore);

    @Select({
            "select * from \n" +
                    "(\n" +
                    "    select award_year from t_achievement_awards\n" +
                    "    UNION all\n" +
                    "    select award_year from t_annual_plan_work\n" +
                    "    UNION all\n" +
                    "    select award_year from t_annual_work_days\n" +
                    "    UNION all\n" +
                    "    select award_year from t_employee_awards_info\n" +
                    "    UNION all\n" +
                    "    select award_year from t_employee_performance\n" +
                    "    UNION all\n" +
                    "    select award_year from t_employee_training\n" +
                    "    UNION all\n" +
                    "    select award_year from t_papers_and_books\n" +
                    "    UNION all\n" +
                    "    select award_year from t_task_info\n" +
                    "    UNION all\n" +
                    "    select award_year from t_training_record\n" +
                    "    UNION all\n" +
                    "    select award_year from t_work_ticket_info\n" +
                    ") t \n" +
                    "where t.award_year is not null\n" +
                    "GROUP BY t.award_year "
    })
    List<Date> getAllIndexYears(EmployeeScore employeeScore);


    @Delete("DELETE FROM t_employee_Score WHERE DATE_FORMAT(award_year, '%Y') = DATE_FORMAT(#{awd}, '%Y')")
    void clearTableYear(Date awd);
}
